package im.oen.boot.common.match.constant;

/**
 * <p>描述：暂无描述信息</p>
 *
 * <p>创建时间：2021-12-17 09:57</p>
 * <p>更新时间：暂无</p>
 *
 * @author Kevin.Xu
 * @version 1.0
 */
public class ModifiableConst {
    public static String _TOWPNTDISTRATIO = "_TOWPNTDISTRATIO";
    public static String _TOWPNTORIENTATIONMINUS = "_TOWPNTORIENTATIONMINUS";
    public static String _TOWPNTSCALAMINUS = "_TOWPNTSCALAMINUS";
    public static String _SLOPEARCSTEP = "_SLOPEARCSTEP";
    public static String _MINPOINTCOUNT = "_MINPOINTCOUNT";

    public static int getMinPointCount() {
        return PropertiesHolder.minPointCount;
    }

    public static float getTowPntDistRatio() {
        return PropertiesHolder.towPntDistRatio;
    }

    public static float getTowPntOrientationMinus() {
        return PropertiesHolder.towPntOrientationMinus;
    }

    public static float getTowPntScaleMinus() {
        return PropertiesHolder.towPntScaleMinus;
    }

    public static int getSolpeArcStep() {
        return PropertiesHolder.solpeArcStep;
    }

    /******************* setteies **********************************/
    public static void setTowPntDistRatio(float val) {
        PropertiesHolder.towPntDistRatio = val;
    }

    public static void setTowPntOrientationMinus(float val) {
        PropertiesHolder.towPntOrientationMinus = val;
    }

    public static void setTowPntScaleMinus(float val) {
        PropertiesHolder.towPntScaleMinus = val;
    }

    public static void setSolpeArcStep(int val) {
        PropertiesHolder.solpeArcStep = val;
    }

    private static class PropertiesHolder {

        // lazyload,
        private static float towPntDistRatio = 0.8f;
        private static float towPntOrientationMinus = 0.05f;
        private static float towPntScaleMinus = 4.0f;
        private static int solpeArcStep = 5;
        private static int minPointCount = 10;

        static {
            String ratio = System.getProperty(_TOWPNTDISTRATIO);
            String orientation = System.getProperty(_TOWPNTORIENTATIONMINUS);
            String scala = System.getProperty(_TOWPNTSCALAMINUS);
            String arcStep = System.getProperty(_SLOPEARCSTEP);
            String minCount = System.getProperty(_MINPOINTCOUNT);
            towPntDistRatio = getFloatValue(ratio, towPntDistRatio);
            towPntOrientationMinus = getFloatValue(orientation, towPntOrientationMinus);
            towPntScaleMinus = getFloatValue(scala, towPntScaleMinus);
            solpeArcStep = getIntValue(arcStep, solpeArcStep);
            minPointCount = getIntValue(minCount, minPointCount);
        }

        private static int getIntValue(String str, int defVal) {
            try {
                return Integer.parseInt(str);
            } catch (Exception e) {
                return defVal;
            }
        }

        private static float getFloatValue(String str, float defVal) {
            try {
                return Float.parseFloat(str);
            } catch (Exception e) {
                return defVal;
            }
        }

    }
}
